#ifndef _CONTROL_H
#define _CONTROL_H

#pragma region Include
#include "debug.h"

#include "parser.h"
#include "response.h"
#include "web_content.h"
#pragma endregion Include 

#define COMMAND				1
#define	WEB_CONTENT			2
#define ROOT_DIR			3
#define UNKNOWN				0

#define DEFAULT_ROOT_DOC	"d:\\www"

class CControl
{
private:
	CRITICAL_SECTION cs1;
	HANDLE mt_create_content;

	char *root_doc;

	char *request_buf;
	int	request_buf_size;

	char *response;
	long response_size;

	CHttpParser *pars;
	CHttpResponse *resp;

	CWebContent *web_cont;

	char *path_buf;
	int path_buf_size;
public:
	CControl();
	~CControl();

	int set_root_document(const char *path);
	//char *get_response(const char *request);
	char *get_response(const char *request);
	long get_response_size();

private:
	int get_request(const char *request);
	char *make_path(const char *URI);
	bool is_command(const char *URI);
	bool is_path_to_page(const char *URI);
	int analyse_URI(const char *URI);
	char* gen_response();
	//char *create_full_msg(const char *head, const char *body);

};

#endif